When i insert "if (descriptions >= 0.4){zien()} then it gets red underlined with error "unreachable code". Why is that??
function loadLabeledImages() {
const labels = ['Simon', 'Thomas'];
return Promise.all(
labels.map(async (label) => {
const img = await faceapi.fetchImage(`./images/${label}.jpg`);
const detections = await faceapi
.detectSingleFace(img)
.withFaceLandmarks()
.withFaceDescriptor();
const descriptions = [detections.descriptor];
return new faceapi.LabeledFaceDescriptors(label, descriptions);
if (descriptions >= 0.4){
zien()
}
}),
);
}
The fact is it an if is irrelevant. It is code that appears after a return statement.
When running the function, the JS engine will always return from the function before reaching the if. Since it can never reach the if, the if is unreachable.